//
//  HMFeatureViewContrller.m
//  OC新浪微博
//
//  Created by wyman on 16/4/13.
//  Copyright © 2016年 wyman. All rights reserved.
//

#import "HMFeatureViewContrller.h"
#import "HMFeatrueCell.h"
@interface HMFeatureViewContrller ()

@end

@implementation HMFeatureViewContrller

static NSString * const reuseIdentifier = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.collectionView registerClass:[HMFeatrueCell class] forCellWithReuseIdentifier:reuseIdentifier];

    
}

-(instancetype)init
{


    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    
    layout.minimumInteritemSpacing = 0;
    
    layout.minimumLineSpacing = 0;
    
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    

    
    if(self = [super initWithCollectionViewLayout:layout]){
        
        
           layout.itemSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height);
            self.collectionView.pagingEnabled = YES;
        
            self.collectionView.bounces = NO;
    };
    
    return self;

}


/**
 *  代理方法
 *
 *  @param NSInteger <#NSInteger description#>
 *
 *  @return <#return value description#>
 */

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
//    [super scrollViewrDidEndDecelerating:scrollView];
    
    //得到偏移值
    int index = (int)self.collectionView.contentOffset.x/([UIScreen mainScreen].bounds.size.width);
    HMLog(@"%d",index);

    if (index == 3) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForItem:index inSection:0];
        [(HMFeatrueCell *)[self.collectionView cellForItemAtIndexPath:indexPath] startRotate];
    }

}





- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of items
    return NumberOfFeature;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HMFeatrueCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
    
    int index = (int)indexPath.item;
    
    
    cell.index = index;
    return cell;
}

#pragma mark <UICollectionViewDelegate>



@end
